package com.linsen.core.common.context;

import com.alibaba.ttl.TransmittableThreadLocal;
import com.linsen.core.common.model.User;

/**
 * 用户数据上下文
 *
 * @author zhaoyong
 * @date 2023/3/11
 */
public final class UserContextHolder {
    private final static TransmittableThreadLocal<User> USER_CONTEXT = new TransmittableThreadLocal<>();

    public static void setUser(User user) {
        USER_CONTEXT.set(user);
    }

    public static User getUser() {
        return USER_CONTEXT.get();
    }

    public static void removeUser() {
        USER_CONTEXT.remove();
    }
}
